package com.kexinxin.util.matching;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import com.kexinxin.bean.Skill;
import com.kexinxin.service.impl.SearchDAOImpl;
import com.kexinxin.util.PoiUtil;


public class Recommend {
	public static List<String> getKeyWord(String path){
		List<String> keyWordList=new LinkedList<String>();
		List<String> skillList=SearchDAOImpl.getSkillNameList();
		String resume=PoiUtil.getDoc(path);
		for(int i=0;i<skillList.size();i++){
			if(resume.contains(skillList.get(i).toLowerCase())){
				keyWordList.add(skillList.get(i));
			}
		}
		return keyWordList;
	}
	
	public static List<String> getRecommend(List<String> keyWordList){
		HashSet<String> set = new HashSet<String>();
		BN bn=new BN();
		for(int i=0;i<keyWordList.size();i++){
			List<Skill> list=bn.matchingResult(keyWordList.get(i));
			if(list.size()==0){
				set.add(keyWordList.get(i));
			}else{
				for(int j=0;j<list.size();j++){
					set.add(list.get(j).getSkillName());
				}
			}
		}
		List<String> result=new LinkedList<String>();
		Iterator it = set.iterator();
		while (it.hasNext())
		{
			String o = (String) it.next();
			result.add(o);
		}

		return result;
	}
	
	public static void main(String[] args) {
		List<String> keyWordList=getKeyWord("D://b.doc");
		for(int i=0;i<keyWordList.size();i++){
			System.out.println(keyWordList.get(i));
		}
		 List<String> list=getRecommend(keyWordList);
		 System.out.println("--------------------------");
		 for(int i=0;i<list.size();i++){
		 System.out.println(list.get(i));
		 }
	}
}
